<?php

namespace App\Http\Controllers\Admin\Meeting;

use App\Http\Controllers\Admin\BaseController;
use App\Http\Controllers\Controller;
use App\Models\MeetingSignin;
use Illuminate\Http\Request;

class SigninController extends BaseController
{
    /**
     * @param Request $request
     * @return array
     */
    public function get(Request $request)
    {
        return ['signin' => MeetingSignin::find($request->input('id'))];
    }

    /**
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     */
    public function batchget(Request $request)
    {
        $query = MeetingSignin::with(['guest']);
        return ajaxReturn([
            'total' => $query->count(),
            'items' => $query->offset($request->input('offset', 0))
                ->limit($request->input('count', 15))
                ->orderByDesc('id')->get()
        ]);
    }

    /**
     * @param Request $request
     */
    public function delete(Request $request)
    {
        MeetingSignin::whereKey($request->input('items', []))->delete();
        return ajaxReturn();
    }
}
